package factory;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ArquivoConfig {

    private Properties props;
    private static ArquivoConfig instance;

    private ArquivoConfig() {
        props = new Properties();
        this.carregaArquivoConfig();
    }

    public static ArquivoConfig getInstance() {
        if (instance == null) {
            instance = new ArquivoConfig();
        }
        return instance;
    }

    public String getPropriedade(String tipo) {
        String valor = props.getProperty(tipo);
        return valor;
    }

    private void carregaArquivoConfig() {

        InputStreamReader fMainProp = new InputStreamReader(this.getClass().getResourceAsStream("config.properties"));
        try {
            props.load(fMainProp);
        } catch (IOException ex) {
            Logger.getLogger(ArquivoConfig.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
